
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
/**
 *
 * @author  diogo
 */
public class OperadorView extends javax.swing.JFrame {

    /** Creates new form OperadorView */
    public OperadorView() {
        initComponents();
        //txtSerial.addKeyListener(new ValidacaoSubProduto());
        txtSerial.addKeyListener(new ValidacaoSubProduto());
        txtOperador.addKeyListener(new ValidacaoOperador());

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtSerial = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        txtOperador = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        listaDefeito = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        listaCadastrosOk = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setLocationByPlatform(true);
        setMinimumSize(new java.awt.Dimension(1024, 768));
        getContentPane().setLayout(null);

        txtSerial.setFont(new java.awt.Font("UnDotum", 1, 18));
        txtSerial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtSerialActionPerformed(evt);
            }
        });
        getContentPane().add(txtSerial);
        txtSerial.setBounds(10, 40, 340, 33);

        jLabel1.setText("NUMERO DE SERIE / CODIGO DE DEFEITO");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(20, 20, 260, 17);

        jLabel2.setText("OPERADOR");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(10, 80, 70, 17);

        jLabel3.setText("PRODUTOS DEFEITO");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(10, 140, 140, 17);

        jLabel4.setText("PRODUTOS CADASTRADOS");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(370, 20, 190, 17);

        jButton1.setText("PESQUISAR");
        getContentPane().add(jButton1);
        jButton1.setBounds(760, 660, 240, 29);

        jButton2.setText("SAIR");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2);
        jButton2.setBounds(760, 700, 240, 29);

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        getContentPane().add(jSeparator1);
        jSeparator1.setBounds(730, 40, 30, 690);
        getContentPane().add(jSeparator2);
        jSeparator2.setBounds(760, 450, 4, 6);

        txtOperador.setFont(new java.awt.Font("UnDotum", 1, 18));
        getContentPane().add(txtOperador);
        txtOperador.setBounds(10, 100, 340, 33);

        jLabel5.setFont(new java.awt.Font("UnDotum", 0, 24));
        jLabel5.setText("POMAR");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(830, 340, 80, 17);

        jLabel6.setText("Product Manager and Reporter");
        getContentPane().add(jLabel6);
        jLabel6.setBounds(780, 360, 190, 17);

        jButton3.setText("TESTE JANELA ERRO");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton3);
        jButton3.setBounds(770, 100, 220, 29);

        jLabel7.setFont(new java.awt.Font("UnDotum", 0, 18));
        jLabel7.setText("Estação de Embalagem");
        getContentPane().add(jLabel7);
        jLabel7.setBounds(780, 40, 200, 30);

        jButton4.setText("TESTE JANELA CAD. DEFEITO");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton4);
        jButton4.setBounds(770, 140, 220, 29);

        listaDefeito.setBackground(new java.awt.Color(184, 174, 168));
        listaDefeito.setColumns(20);
        listaDefeito.setEditable(false);
        listaDefeito.setFont(new java.awt.Font("UnDotum", 1, 18)); // NOI18N
        listaDefeito.setForeground(new java.awt.Color(204, 1, 1));
        listaDefeito.setRows(5);
        listaDefeito.setPreferredSize(new java.awt.Dimension(300, 18));
        jScrollPane1.setViewportView(listaDefeito);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(10, 160, 340, 570);

        listaCadastrosOk.setBackground(new java.awt.Color(184, 174, 168));
        listaCadastrosOk.setColumns(20);
        listaCadastrosOk.setEditable(false);
        listaCadastrosOk.setFont(new java.awt.Font("UnDotum", 1, 18)); // NOI18N
        listaCadastrosOk.setForeground(new java.awt.Color(0, 128, 3));
        listaCadastrosOk.setRows(27);
        listaCadastrosOk.setFocusable(false);
        listaCadastrosOk.setPreferredSize(new java.awt.Dimension(300, 27));
        jScrollPane2.setViewportView(listaCadastrosOk);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(370, 40, 340, 690);

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void txtSerialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtSerialActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtSerialActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
    new ErrorView().setVisible(true);
}//GEN-LAST:event_jButton3ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton2ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
    new CadastroDefeito().setVisible(true);
}//GEN-LAST:event_jButton4ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new OperadorView().setVisible(true);
            }
        });
    }
    
    public class ValidacaoSubProduto implements KeyListener {

        public void keyTyped(KeyEvent arg0) {}

        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_ENTER){
                
                //Inserir o codigo de validacao do produto
                
                //passa o foco do componete para o textfield do operador
                txtOperador.requestFocus(true);
            }
        }

        public void keyReleased(KeyEvent arg0) {}
    }
    
    /**
     * 
     */
    public class ValidacaoOperador implements KeyListener {

        public void keyTyped(KeyEvent arg0) {}

        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_ENTER){
                
                //Inserir o codigo de validacao do produto
                
                
                
                //passa o foco do componete para o textfield do operador
                listaDefeito.insert(txtSerial.getText() + "\n", 0);
                listaCadastrosOk.insert(txtSerial.getText() + "\n", 0);
                txtSerial.setText("");
                txtOperador.setText("");
                txtSerial.requestFocus(true);
            }
        }

        public void keyReleased(KeyEvent arg0) {}
    }
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextArea listaCadastrosOk;
    private javax.swing.JTextArea listaDefeito;
    private javax.swing.JTextField txtOperador;
    private javax.swing.JTextField txtSerial;
    // End of variables declaration//GEN-END:variables

    
}
